package codediff.parse.report;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.collect.Lists;
import lombok.Setter;

import java.util.List;

@Setter
@JsonIgnoreProperties(ignoreUnknown = true)
public class CoveragePackage {
    private String name;
    @JsonProperty(value = "class", access = JsonProperty.Access.WRITE_ONLY)
    private List<CoverageClass> coverageClasses = Lists.newArrayList();
    @JsonProperty(value = "sourcefile", access = JsonProperty.Access.WRITE_ONLY)
    private List<CoverageSourceFile> sourceFiles = Lists.newArrayList();
    @JsonProperty("counter")
    private List<Counter> counters = Lists.newArrayList();

    private List<CoverageMergeClass> coverageMergeClasses = Lists.newArrayList();

    @JsonIgnore
    public void mergeClass() {
        coverageMergeClasses = CoverageMergeClass.mergePackages(coverageClasses, sourceFiles);
    }

    public String getName() {
        return name;
    }

    public List<Counter> getCounters() {
        return counters;
    }

    public List<CoverageMergeClass> getCoverageMergeClasses() {
        return coverageMergeClasses;
    }
}
